package com.hckj.jianzhijia.popupwindows;

import android.content.Context;
import android.view.View;

import com.hckj.jianzhijia.model.City;
import com.hckj.jianzhijia.utils.Data;

import java.util.ArrayList;

/**
 * Created by 赵奇隆 on 2015-10-29.
 */
public class PublishPopupWindowCity extends ListPopupWindow {

    private PublishPopWinCityInterface publishPopWinCityInterface;
    private ArrayList<City> cities;


    public static PublishPopupWindowCity newInstance(Context context,PublishPopWinCityInterface publishPopWinCityInterface, View parentView,ArrayList<City> cities){
        String[] data = new String[cities.size()];
        for(int i=0,j=cities.size();i<j;i++){
            data[i] = cities.get(i).getCity();
        }

        return new PublishPopupWindowCity(context, publishPopWinCityInterface, parentView, cities, data);
    }

    public PublishPopupWindowCity(Context context,PublishPopWinCityInterface publishPopWinCityInterface, View parentView,ArrayList<City> cities,String[] data) {
        super(context, parentView, null, data);
        this.publishPopWinCityInterface = publishPopWinCityInterface;
        this.cities = cities;
    }

    public  interface PublishPopWinCityInterface{
        public void setCity(int position,String itemName);
    }

    @Override
    public void getListItem(int position, String itemName) {
        publishPopWinCityInterface.setCity(cities.get(position).getCityId(), itemName);
    }

}
